package com.holdtime.wisdomdrone.openapi.web.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import com.holdtime.framework.openapi.core.annotations.OpenApiValidate;
import com.holdtime.wisdomdrone.module.service.UploadOssFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * author: qzj
 * Date: 2025/2/25 11:25
 * Description: 开放接口类
 */
@Tag(name = "开放接口", description = "开放接口")
@RestController
@Validated
@RequestMapping("/openApi")
public class WisdomDroneOpenApiController {

    @Resource
    private UploadOssFileService uploadOssFileService;

    @OpenApiValidate
    @PostMapping("/v1/uploadOssFileByKey")
    @Operation(summary = "通过OSSKey上传文件", description = "通过OSSKey上传文件")
    public CommonResult<?> uploadOssFileByKey(
            @RequestParam("ossKey") @NotNull(message = "OSSKey不为能空") @Parameter(name = "ossKey", in = ParameterIn.QUERY, description = "OSSKey", required = true) String ossKey,
            @RequestParam("path") @NotNull(message = "path不为能空") @Parameter(name = "path", in = ParameterIn.QUERY, description = "文件路径", required = true) String path,
            @RequestParam("ts") @NotNull(message = "时间戳不能为空") @Parameter(name = "ts", in = ParameterIn.QUERY, description = "时间戳", required = true) String ts,
            @RequestParam("sign") @NotNull(message = "签名不能为空") @Parameter(name = "sign", in = ParameterIn.QUERY, description = "签名", required = true) String sign,
            @RequestParam("user") @NotNull(message = "用户编码不能为空") @Parameter(name = "user", in = ParameterIn.QUERY, description = "用户编码", required = true) String user) {
        return success(uploadOssFileService.uploadOssFileByKey(ossKey,path));
    }
}
